﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;


namespace LiveProjectManager.DDD
{
    public class EntityContext : DbContext
    {
        private static EntityContext _instance = null;

        public DbSet<Domains.Config> ConfigRepository { get; set; }

        public DbSet<Domains.User> UserRepository { get; set; }

        public DbSet<Domains.Task> TaskRepository { get; set; }

        public DbSet<Domains.Category> CategoryRepository { get; set; }

        public DbSet<Domains.Resource> ResourceRepository { get; set; }

        public DbSet<Domains.File> FileRepository { get; set; }

        public DbSet<Domains.Post> PostRepository { get; set; }

        public DbSet<Domains.PostComment> PostCommentRepository { get; set; }


        public static EntityContext Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new EntityContext();
                return _instance as EntityContext;
                /*string ecKey = "ocm_" + HttpContext.Current.GetHashCode().ToString("x");
                if (!HttpContext.Current.Items.Contains(ecKey))
                    HttpContext.Current.Items.Add(ecKey, new EntityContext());
                return HttpContext.Current.Items[ecKey] as EntityContext;*/
            }
        }
    }
}